package com.ruoyi.club.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.club.domain.ClubInfo;
import com.ruoyi.club.service.IClubInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 社团信息Controller
 * 
 * @author Zou
 * @date 2025-11-14
 */
@RestController
@RequestMapping("/club/info")
public class ClubInfoController extends BaseController
{
    @Autowired
    private IClubInfoService clubInfoService;

    /**
     * 查询社团信息列表
     */
    @PreAuthorize("@ss.hasPermi('club:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(ClubInfo clubInfo)
    {
        startPage();
        List<ClubInfo> list = clubInfoService.selectClubInfoList(clubInfo);
        return getDataTable(list);
    }

    /**
     * 导出社团信息列表
     */
    @PreAuthorize("@ss.hasPermi('club:info:export')")
    @Log(title = "社团信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ClubInfo clubInfo)
    {
        List<ClubInfo> list = clubInfoService.selectClubInfoList(clubInfo);
        ExcelUtil<ClubInfo> util = new ExcelUtil<ClubInfo>(ClubInfo.class);
        util.exportExcel(response, list, "社团信息数据");
    }

    /**
     * 获取社团信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('club:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(clubInfoService.selectClubInfoById(id));
    }

    /**
     * 新增社团信息
     */
    @PreAuthorize("@ss.hasPermi('club:info:add')")
    @Log(title = "社团信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClubInfo clubInfo)
    {
        return toAjax(clubInfoService.insertClubInfo(clubInfo));
    }

    /**
     * 修改社团信息
     */
    @PreAuthorize("@ss.hasPermi('club:info:edit')")
    @Log(title = "社团信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClubInfo clubInfo)
    {
        return toAjax(clubInfoService.updateClubInfo(clubInfo));
    }

    /**
     * 删除社团信息
     */
    @PreAuthorize("@ss.hasPermi('club:info:remove')")
    @Log(title = "社团信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(clubInfoService.deleteClubInfoByIds(ids));
    }
}
